﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class MaritalStatusBL
	{

		#region ***** Init Methods ***** 
		MaritalStatusDA objMaritalStatusDA;
		public MaritalStatusBL()
		{
			objMaritalStatusDA = new MaritalStatusDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get MaritalStatus by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>MaritalStatus</returns>
		public MaritalStatus GetByID(int id,int PersonalProfileID)
		{
            return objMaritalStatusDA.GetByID(id, PersonalProfileID);
		}

		/// <summary>
		/// Get all of MaritalStatus
		/// </summary>
		/// <returns>List<<MaritalStatus>></returns>
		public List<MaritalStatus> GetList()
		{
			string cacheName = "lstMaritalStatus";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objMaritalStatusDA.GetList(), "MaritalStatus");
			}
			return (List<MaritalStatus>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of MaritalStatus
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetOld()
		{
			string cacheName = "dsMaritalStatus";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objMaritalStatusDA.GetDataSetOld(), "MaritalStatus");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}

        public DataSet GetDataSet(int PersonalProfileID)
        {
            string cacheName = "dsMaritalStatus";
            ServerCache.Remove("dsMaritalStatus");
            if (ServerCache.Get(cacheName) == null)
            {
                ServerCache.Insert(cacheName, objMaritalStatusDA.GetDataSet(PersonalProfileID), "MaritalStatus");
            }
            return (DataSet)ServerCache.Get(cacheName);
        }

		/// <summary>
		/// Get all of MaritalStatus paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<MaritalStatus>></returns>
		public List<MaritalStatus> GetListPaged(int recperpage, int pageindex)
		{
			return objMaritalStatusDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of MaritalStatus paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objMaritalStatusDA.GetDataSetPaged(recperpage, pageindex);
		}

		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new MaritalStatus within MaritalStatus database table
		/// </summary>
		/// <param name="obj_maritalstatus">MaritalStatus</param>
		/// <returns>key of table</returns>
		public int Add(MaritalStatus obj_maritalstatus)
		{
			ServerCache.Remove("MaritalStatus", true);
			return objMaritalStatusDA.Add(obj_maritalstatus);
		}

		/// <summary>
		/// updates the specified MaritalStatus
		/// </summary>
		/// <param name="obj_maritalstatus">MaritalStatus</param>
		/// <returns></returns>
		public void Update(MaritalStatus obj_maritalstatus)
		{
			ServerCache.Remove("MaritalStatus", true);
			objMaritalStatusDA.Update(obj_maritalstatus);
		}

		/// <summary>
		/// Delete the specified MaritalStatus
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("MaritalStatus", true);
			objMaritalStatusDA.Delete(id);
		}
		#endregion
	}
}
